Skip to content

Reimplement UpdatePeasant and UpdateMiller from gynt's units branch, under /GL (100%) - #533

Merged
gynt merged 2 commits into
sourcehold:mainfrom
kotijekriv:reimpl/units-A-round10-100
Nov 30, 2026
Merged

gynt merged 2 commits into
sourcehold:mainfrom
kotijekriv:reimpl/units-A-round10-100

Conversation

@kotijekriv

Copy link
Copy Markdown
Contributor

Two more Map::Units update functions, from gynt's units branch reimpl/map-units-updatefunctions (his draft #204). We had them at 100% on our development branches on top of #378 and #421 before those merged. On main a841629 the same statements read 96.0% and 96.3%; #238 has since put more of their callees under /GL, and on main 210546f (which now has #518's two archers) they read 100.0%. These are those texts after one text pass (BOOLEnum calls tested by truthiness, casts that change nothing dropped, const on locals, comments without addresses; each commit lists its own). Each reads 100.0% in the default build with its own line in cmake/compiler-flags-gl.txt. Each commit cites gynt's commits on the file and our steps on it, and credits him as co-author. The text work on both began on another of our development branches, written with Claude Fable 5.2; the commits keep that co-author line. No header change and no change to cmake/function-visibility.txt.

Function Address Before After
Units::UpdatePeasant 0x0053EAA0 gynt's draft 37.12% (d2b6f9e) 100.0%, under /GL; 49.3% with OPENSHC_FUNCTION_VISIBILITY_UNITS on
Units::UpdateMiller 0x00554CC0 gynt's draft 35.76% (9172ce9) 100.0%, under /GL; 51.7% with the option on

"Before" is the status of gynt's last measured commit on each file (his style-pass commits). His later commits on the files were not measured: 6565c1b renames UpdatePeasant's campground fields to main's header, and 974c32f moves one include line in both.

Measured.

  • Setup: the bundled MSVC1400-SP1 against the Steam Stronghold Crusader.exe (3bb0a8c1…5387ac5a), both resolver sets enabled locally (not committed), and sourcehold's reccmp (a86aceb03) with --resolve-wrapped-calls --ignore-security-cookie.
  • Builds on main 210546f, head on ff7e56e: the full builds are of the head on main 210546f. The branch was then cut again from ff7e56e; the rebase brought only Reimplement 9 static constructors at 100% #524's static constructors (nine new files, and an include moved in the other Global/Init files) and Reimplement calculatePathKeepAndWallsGatesNotAllowed, findAppropriateLocationForSiegeTent and tracePathPlanToDestinationViaUnoccupiedTiles from gynt's PathFindingState draft (#373) (100%) #532's three PathFindingState functions (new .cpp files and status lines, no /GL line), with no header or cmake change. The small builds below were run on 210546f and on the final head.
  • Full builds, both modes: every .cpp of this branch on main 210546f (main plus the two files), all function and data resolvers on, built once with the option off and once with it on, 0 failures, 3,015 files and 3,033 functions each, against main 210546f built the same way (3,013 files, 3,031 functions).
  • Small builds, both modes: main 210546f with the two files and their /GL lines, their callees, every /GL file of main and every file of a function-visibility group that touches them: 453 files, 463 functions, 0 failures in both modes. Both read 100.0% / 100.0% (normalised) with the option off; with it on they read as in the full build, and main's UpdatePriest reads 72.0% / 68.9% there as in main's own builds. The same small builds of the final head on ff7e56e, after the review's text fixes (453 files, 463 functions, 0 failures in both modes), read the same.
  • Text pass, before those builds: quick_diff gives the same listing for each file before and after every edit.
  • Review pass: the fade step stored as -1, const on two more locals (UpdateMiller's second granary lookup now has a local of its own) and the comments under "Kept as they are". quick_diff (with the resolvers as a real build has them) gives the same listing before and after. One edit changed it and is not in: workplace for UpdateMiller's two re-reads of workplaceBuildingID_1 (178 lines).
  • Checks: the style checks (the maintainers' review asks and main's style_lint.py) and the status lines: nothing to fix automatically, no errors and 42 notes, all of the kinds below.
  • Not run in game.

With OPENSHC_FUNCTION_VISIBILITY_UNITS on

Neither has an entry in cmake/function-visibility.txt. In that mode the callees the units' wrapper holds leave the /GL list, so these units can't see them and read lower: UpdatePeasant 49.3% / 48.7%, UpdateMiller 51.7% / 46.2%. Main's UpdatePriest, a /GL unit without an entry too, does the same in main's full builds (100.0% off, 72.0% / 68.9% on), as do the eight units of #516 and #518. Entries that name each unit's whole /GL callee closure are left for a follow-up, with their own full build in that mode.

Kept as they are

  • Ternaries (5, UpdatePeasant): the substate picks behind the idle state. The original computes each without a branch (sete / sbb); an if / else gives a branch. Each has a one-line comment on the line above its ?; the style-lint bot will still list the three whose ? and : stand on one line.
  • (char) on engineerManningSiegeStateRef_checkType (three times in UpdatePeasant, once in UpdateMiller): the field holds the fade step that is added to the char fade countdown, so the tests read it signed. It is a byte in the header (as in Reimplement UpdateCamel, UpdateLady, UpdateMother and UpdateFireEater from gynt's units branch, under /GL (100%) #515, Reimplement UpdateChild, UpdateWheatFarmer, UpdateCrossbowman, UpdateLadderman, UpdateTunneler and UpdateFireThrower from gynt's units branch, under /GL (100%) #516 and Reimplement UpdateArabianArcher and UpdateCrusaderArcher from gynt's units branch, under /GL (100%) #518).
  • (short) stores: the slot into the mill's workers[] and unitID, as main's unit functions write it, and the int peasant count into the short idInTribe.
  • BOOLEnum calls tested by truthiness, int calls compared with 0: buildingIsAccessible and canBuildingStoreTheAmount return int and keep their != 0; the flags seated, isDisappearingUnk, goToRallyPoint, peasantAlwaysZero and killedFlagUnk (and unitTypeSpecificRestingState and field_0x2ac, which are stored) are two-byte short fields, where a four-byte BOOLEnum would not fit the layout, so they are compared with 0, as are the move-delay and run-up counters and the undefined4 DAT_UnitHasBecomeIdle, as main does.
  • Arms the original keeps although they look redundant, each with a one-line comment: UpdatePeasant's walk-speed block ends in two arms that store the same values (the original keeps that compare, with no jump behind it); UpdateMiller's idle state has its own arm for substate 106 though it reads the default's table (the original tests for it), and its states are one if / else-if chain whose arms fall out of it.
  • Calls and copies the original has, each with a one-line comment: UpdatePeasant calls moveUnitAroundCampfire twice with the same arguments (== -1, then > 0), as the original does, and its campfire state stores the whole sprite in each of its four orientation arms, where only the added number differs: the original keeps a full copy in each.
  • workplaceBuildingID_1 read from the unit again in UpdateMiller's fade state and disappear state, though workplace holds it: the original loads it again there, and with workplace quick_diff gives another listing (178 lines). Each has a one-line comment.
  • field_0x58 = 1 (UpdateMiller): the checker's BOOLEnum hint comes from another struct's field_0x58 (SoundEffectsHelperData1); Unit::field_0x58 is a short, and main's UpdateHopsFarmer stores 1 and 0 into it too.
  • The checker's other notes are Ghidra's placeholder field names. The frame tables and the campground's two counters are listed under "Names on main these files show"; for the rest (Unit::field_0x56, the peasant's facing at the campfire, copied into facingDirection; Unit::field_0x58; field_0x2ac) we have nothing better yet.

Differences from the draft

None that reads a test the other way. We compared every test against a number in both files with gynt's drafts. Where ours is written the other way round, it means the same: UpdateMiller's six branches turned round with their arms exchanged (its commit lists them: <= 0 behind getBuildingResourceAmountByUid, >= 20 in the flour state, and four calls), UpdatePeasant's idle test as cycle > 16 setting the flag where the draft returned on <= 16, and its next-animation block with the peasantAlwaysZero != 0 arm first. The draft's campfire orientation tests == 4, == 2 and == 6 are MO_SOUTH, MO_EAST and MO_WEST, its hex substates are decimal, and its other extra == 0 tests are BOOLEnum calls, now tested by truthiness, and the substate switch, now an if / else-if chain.

Header follow-ups

Each of these is a header that functions on main use, so it goes in a PR of its own, with full builds of main's users in both modes (#515, #516 and #518 leave them the same way):

  • DAT_UnitHasBecomeIdle holds only 0 and 1: as a BOOLEnum, every use in these files would store TRUE / FALSE and test by truthiness.
  • Unit::engineerManningSiegeStateRef_checkType holds a signed fade step: as a char, the four (char) casts here go.

Names on main these files show (follow-ups, not changed here)

  • Building::field_0x270 and field_0x272 on the campground are peasant counters: UpdatePeasant adds one to field_0x270 on each update of a peasant idling at the campfire, and one to field_0x272 on each update of a peasant walking to its place there.

  • PlayerData::count counts the peasants coming to the campfire (UpdatePeasant adds one while a peasant appears there, walks there or warms up there), and count_2 the peasants turning into soldiers.

  • The mill uses Building::killingPitField as its stage (a miller takes the mill only while it is 0 and has no unitID; at 3 the grinding is done and he leaves with the flour), and outpostRelatedUnk4 is set to 300 when a miller starts grinding.

  • Unit::calculatedOwnerPlayerIndex holds fixedRng & 7 for a peasant.

  • The frame tables (UnitPropertiesDefinedData) these files read, by the state that reads each; renaming them is a header change, so they stay as they are here:

    Table What it holds
    field_0x451c / field_0x45ac peasant standing at the campfire (substates 102 / 103)
    field_0x4610 / field_0x4638 peasant sitting down / standing up (101 / 100)
    field_0x466c / field_0x46c4 / field_0x4724 / field_0x4794 peasant sitting at the campfire (106 / 107 / 110 / 111)
    field_0x4804 / field_0x485c / field_0x489c / field_0x4904 peasant standing, the peasantAlwaysZero animations (114 to 117)
    field_0x498c / field_0x49c4 peasant substates 118 and 120
    field_0x5ba0 / field_0x5bc0 miller standing up / sitting down (100 / 101)
    field_0x5be0 / field_0x5c24 miller sitting (106 / 107; field_0x5be0 for any other substate too)

Other PRs

  • gynt's Reimpl/map units updatefunctions #204 holds these files too. Once this lands, his branch can take main's version of them.
  • Main ff7e56e still has the 12 files that don't compile since Reimplement 59 TextManager and UserTextHandler functions at 100% #509's sync (renderDebugDataCurrentPlayerData, applyGateOrDrawbridgeOpenCloseChange, initializeGatePathfindingForOwner, updatePathLinkageTileMap, UpdateGateHouseLarge, UpdateGateHouseSmall, UpdateWoodGate1, findBestAttackTileByPathCost, resetTileAndClearMoat, GateOpenOrClose, ClickOpenOrCloseGate, TransformAndRenderPercentage). All the builds above left them out, with their resolvers off. This PR doesn't touch them.

🤖 Generated with Claude Code

kotijekriv and others added 2 commits November 30, 2026 17:00
Units::UpdatePeasant at 100%, from Gynt's draft on sourcehold's reimpl/map-units-updatefunctions (his draft
PR 204; his commits on the file: a61c888 at 31.61% and the style commit d2b6f9e at 37.12%), through the forms
on our development branches. The statements are his; what the text needed is how they are arranged:

1. State 8 (idling at the campfire, 17 substates): one idle test behind the substate chain. Every last-frame
   arm sets the flag, no running-frame arm tests it, the last arm is `else if (cycle > 16) { flag = 1; }`, and
   behind the chain stands `if (flag == 0) return;`. In the original the running-frame arms jump to the test at
   0x0053F71C and the last-frame arms jump past it to 0x0053F728: the compiler threads them and drops their
   flag stores, because the flag is cleared right behind the test.
2. The campfire state (US_AIM_WEAPON) in the same idiom: the last frame only sets the flag, the four
   orientation arms each compute the whole gfxNumber (three full copies in the original, 0x0053ED0C,
   0x0053ED55, 0x0053ED7E), and one `if (flag != 0) { cycle = 0; state = 0; }` behind both. The original
   compares the flag with an immediate (0x0053ED2A) and makes its zero register behind the branch (0x0053ED37).
3. The move state's walk-speed block: the delayed arm first, then two equal stand-still arms on
   movementRunUpTime: the original keeps that compare with no jump behind it (0x0053EDE2).
4. Choosing the next animation: the peasantAlwaysZero != 0 arm first.

Before 1 was found, every fix in another state made state 8's registers worse (+21 instructions): a structure
that is wrong in one place shows up as register differences in another.

On main, this round's text pass: the `(char)` casts on the 18 frame-table reads dropped (all `char` in main's
AnimationFrameData.hpp); `const` on the three locals that are assigned once; the empty arm in front of the idle state
written as that state's own `==` test; the five ternary comments without addresses; a comment on the walk-speed
block's last two arms, which store the same values. After the review: the fade step stored as -1 (255 before), as
main's UpdatePriest, UpdateEngineer and UpdateMerchant store theirs into this byte; `const` on the substate-119
direction; comments on the second moveUnitAroundCampfire call (the original calls it again) and on the four
orientation arms of the campfire state (the original keeps a full copy in each). The quick_diff listing is the same
before and after.

Measured with real builds (bundled MSVC1400-SP1, function and data resolvers on locally, reccmp raw / normalised), on
main 210546f: a narrow build (453 files: main's /GL files, the two units of this branch with their callee
closures, every file of a function-visibility group that touches them) and a full build of every file (3,015 files,
3,033 functions), each once with OPENSHC_FUNCTION_VISIBILITY_UNITS off and once with it on, BUILD_OK all four. It
reads 100.0 / 100.0 with the option off in both. With it on it reads 49.3 / 48.7 in both: it has no entry in
cmake/function-visibility.txt, so the callees the units' wrapper holds leave the /GL list in that mode (main's
UpdatePriest, a /GL unit without an entry, reads 72.0 / 68.9 there for the same reason). The branch was then cut
again from ff7e56e, which adds only sourcehold#524's nine static constructors (the other Global/Init files there only move
an include) and sourcehold#532's three PathFindingState functions (new files and status lines; no header, cmake or /GL change).
After the review's text fixes, a narrow build of it made the same way reads 100.0 / 100.0 with the option off and
49.3 / 48.7 with it on.

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Units::UpdateMiller at 100%, from Gynt's draft on sourcehold's reimpl/map-units-updatefunctions (his commits on the
file: dff3fd0 at 26.39%, 9172ce9 at 35.76%, and the style commit 974c32f), through the forms on our
development branches, where its history is. It needs ConsiderHavingABreakNowUnk and setupUnitSharingTileIDs under
/GL; main's /GL list has both now.

What the match needed, against the draft (reccmp raw on the development branch, on the /GL list; the draft as
it stood there read 67.2):

- Every access reads the unit through DAT_CurrentUnitSlotID::instance, and the draft's local copy `int unitID`
  is gone: the original keeps the global itself in a register and loads it again only behind a call that may
  change it, which a local copy never does (67.2 -> 73.0).

- Six branches the way round the original has them. Each negates one condition and exchanges the two blocks it
  chooses between: the amount test behind getBuildingResourceAmountByUid in state 3 (the empty granary first);
  the cycle test in US_LOOK_AROUNDUnk (>= 20 first); canBuildingStoreTheAmount and, in its other arm,
  buildingIsAccessible in US_STAND_UPUnk (the call that works first, both); and two early exits that are now
  the else of the call that works, with the rest as the if body: behind setDestinationForUnit in state 2 and
  behind the last setWorkplaceBuildingEntryAsTarget of US_STAND_UPUnk. The cycle test was in the 67.2 already.
  Four came from a search (73.0 -> 90.0) that had also turned the frame test of a death state; that one was
  wrong and is not in this commit: the draft's order there, the last frame first, is the original's. The exit
  behind setDestinationForUnit came last (92.7 -> 94.2).

- In the idle state the frame table is chosen by an if / else-if chain over the substate where the draft had a
  switch; each arm stores the frame into animationFrame itself, as in the draft. The original compares the
  substate with 100, 101, 106 and 107 one after another and has the frame in edx in every arm (0x00554DC2,
  0x00554DD7, 0x00554DF2, 0x00554E01), copies it to eax at the join (0x00554E08) and stores edx (0x00554E0C).
  The arm for 106 is written out though it reads the default's table: the original tests for it (90.0 -> 91.4).

- The states are one if / else-if / else chain whose arms fall out of it, where the draft had a block per state
  that returns: the else parts of US_DEATH_01 and of the alive-check arm end in the same instructions, and
  falling out of a chain the compiler keeps the later copy, as the original does (94.2 -> 95.3, together with a
  local for the idle state's frame that the next step took out again).

- The state is read behind the store into the workplace's workers[], where the draft read it in front. The
  original finishes the index (workerIndex + workplace * 406, the add at 0x00554CF4) before it loads the state
  (0x00554CF6), and so has edx free for the product. It pays only together with the stores per arm of the idle
  state: the read alone 0.9834 in quick_diff, the stores alone 0.9767, both 0.9960 from 0.9820 (95.3 -> 96.8).

- The compiler has to see what the original's compiler saw. The original keeps the slot in edi and its offset
  in esi across UpdateWorker_ConsiderTakingABreakUnk (the call at 0x00554F69, the fields read through esi from
  0x00554F79, push edi at 0x00554F8A) and across commitUnitLocation (the call at 0x005556E7, the read through
  esi at 0x005556EC), and reads the slot again behind setDestinationForUnit (0x00554F99). Ours knows that those
  two calls leave DAT_CurrentUnitSlotID alone only when it sees their bodies and the bodies below them:
  ConsiderHavingABreakNowUnk for the break check (91.4 -> 92.1), setupUnitSharingCurrentTilePosition and
  setupUnitSharingTileIDs for commitUnitLocation (96.8 -> 100.0, the last step). standUpIfSeated, a leaf, has to
  be visible too (92.1 -> 92.7).

The text follows main's unit functions: no compare with TRUE or FALSE (the BOOLEnum results are tested by
truthiness), main's names for the states and for DNE_UNKNOWN_2, const on the locals that are assigned once, the steps
by one as ++ and --, and short whys.

compiler-flags-gl.txt gets UpdateMiller.cpp only: every callee it has to see is on main's list already. Leaving one
out at a time (quick_diff with the /GL callees in the unit, 0.9987 with all of them: the one line it shows, 0xffff
against -0x1, is the same instruction), it needs thirteen, all on main's list now:
- hasUnitReachedDestination (0.9606 without it), getBuildingResourceAmountByUid (0.9735),
  checkIfCitizenUnitIsAliveBasedOnState (0.8021), commitUnitLocation (0.9960);
- ComputeGoodsProduced (0.9674), IncrementAndOptionalUpdateAVValueRelated (0.8455),
  SetStateToFreetimeWalking (0.9721), UpdateWorker_ConsiderTakingABreakUnk (0.9927),
  ConsiderHavingABreakNowUnk (0.9927; they came with PR 421);
- setupUnitSharingCurrentTilePosition (0.9960), sitDownIfStanding (0.9967), standUpIfSeated
  (0.9927), setupUnitSharingTileIDs (0.9960; they came with PR 378).
Nine more on the list make no difference to it (0.9987 without each): addResourceToStockpile,
buildingIsAccessible, getStorageBuildingForResourceTypeAndAmount, updateBuildingSignpostCounter,
makeUnitStopWalkingByClearingPathProgressState, resetUnitMovementState, commitPendingUnitPosition,
setMoveDelayForUnitsOnSameTiles, setWorkplaceBuildingEntryAsTarget. Two callees that are not on main's list must
stay off it for this function: with setLastEncounteredTroopUnit visible it reads 0.9960, with
canBuildingStoreTheAmount 0.9840. (The leave-one-out ran before those PRs merged, on a local tree with PR
378's files and the same callee lines, on the development text, one style step before this one.)

On main, this round's text pass: standUpIfSeated and SetStateToFreetimeWalking, both BOOLEnum, tested by truthiness
like the other calls; the `(char)` casts on the seven frame-table reads and on the three fade-countdown tests dropped
(all `char` in main's AnimationFrameData.hpp and Unit.hpp). After the review: the granary found again in state 3 in a
`const` local of its own (`otherGranary`), so `granary` is `const` too; the idle state's comment on one line; a
comment on the two places that read the workplace from the unit again (with `workplace` there, the listing changes).
The quick_diff listing is the same before and after.

Measured with real builds (bundled MSVC1400-SP1, function and data resolvers on locally, reccmp raw / normalised), on
main 210546f: a narrow build (453 files: main's /GL files, the two units of this branch with their callee
closures, every file of a function-visibility group that touches them) and a full build of every file (3,015 files,
3,033 functions), each once with OPENSHC_FUNCTION_VISIBILITY_UNITS off and once with it on, BUILD_OK all four. It
reads 100.0 / 100.0 with the option off in both. With it on it reads 51.7 / 46.2 in both: it has no entry in
cmake/function-visibility.txt, so the callees the units' wrapper holds leave the /GL list in that mode (main's
UpdatePriest, a /GL unit without an entry, reads 72.0 / 68.9 there for the same reason). The branch was then cut
again from ff7e56e, which adds only sourcehold#524's nine static constructors (the other Global/Init files there only move
an include) and sourcehold#532's three PathFindingState functions (new files and status lines; no header, cmake or /GL change).
After the review's text fixes, a narrow build of it made the same way reads 100.0 / 100.0 with the option off and
51.7 / 46.2 with it on.

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

Style guide reading (advisory, posted once)

3 possible deviation(s) from REIMPLEMENTATION_STYLE_GUIDE.md across 1 of the 2 reimplemented .cpp file(s) in this PR.

The match comes first. Where the ugly form is what matched, it stays -- that is the guide's own overriding rule, and rule 21 asks for a one-line comment saying what was measured so the next reader does not retry it. This report is posted once, when the PR opens, and is not repeated on later pushes.

rule what it asks hits
23 Prefer if-else over ternary 3
Where

Rule 23 — Prefer if-else over ternary

  • src/OpenSHC/Map/Units/UpdatePeasant.cpp:684 — ternary; the guide prefers extending the if-else chain
  • src/OpenSHC/Map/Units/UpdatePeasant.cpp:689 — ternary; the guide prefers extending the if-else chain
  • src/OpenSHC/Map/Units/UpdatePeasant.cpp:696 — ternary; the guide prefers extending the if-else chain

@gynt
gynt added this pull request to the merge queue Nov 30, 2026
Merged via the queue into sourcehold:main with commit 4307ac4 Nov 30, 2026
5 checks passed
kotijekriv added a commit to kotijekriv/OpenSHC that referenced this pull request Dec 1, 2026
…er and UpdateSlave from gynt's units branch (100%, three with OPENSHC_FUNCTION_VISIBILITY_UNITS on) (sourcehold#537)

* reimplement: SHC_3BB0A8C1_0x0053C300 100.0% Reimplemented

Units::UpdateShield at 100%, from Gynt's draft on sourcehold's reimpl/map-units-updatefunctions (his commits on the
file: f791380 at 49.29%, cf15f54 at 52.39%, 6565c1b, 8ca7861 (the file again, whole) and the style commit
974c32f), through the forms on our development branches, where its history is (94.0% there, on main 1f87a13).

What the match needed, against the draft:

- The state it starts in is picked by an if / return pair, as in main's UpdateBatteringRam (sub / neg / sbb / and at
  0x0053C382); the draft had a ternary.
- Every access reads the unit through DAT_CurrentUnitSlotID::instance; the draft's local copy `int unitID` is gone.
- The scan for engineers tests its six conditions as six `if (...) { continue; }` statements, the counts are cleared
  with memset, the distances compare with the engineer first, and the tests read `> 16` and `< 1`, as the original
  compares. The tick test reads `^ 8` where the draft had `^ 0xfffffff8`, the same value under `& 15`.
- The AI check's loop and the two blocks that send the engineer to work are loops of one over manningEngineerRef and
  engineerIDs[9][1]: the first is a loop in the original too (0x0053C4C3), the others make it compute the unit's offset
  anew (0x0053C4D9, 0x0053C744), the start of a loop the compiler unrolled. Written out with index 0 (the first as a do
  / while (0), as its tests break out of it), they read 0.7650, 0.9848 and 0.9913 in quick_diff, against 0.9978.
- The search for the capturing owner is a for loop from 1 to 8 with a found flag, the source form that matches (the
  binary has no flag: the loop at 0x0053C6A7 returns at its end, 0x0053C6B4), and, the last step, it has a local of its
  own that is copied behind the capture, as in main's UpdateBatteringRam, where the parked text searched in the local
  that holds the shield's owner. With it the scan's bound stays in ebx (loaded at 0x0053C57F, compared at 0x0053C682):
  0.9859 -> 0.9978 in quick_diff with the /GL callees in the unit (the one line left, 0xffff against -0x1, is the same
  instruction). The bound read as the global itself instead of through a local came first (0.9827 -> 0.9859).
- createTribe gets the owner of units[searched], where searched is the counter the scan left behind (0x0053C70F); the
  draft passed the shield's own owner. The same call is in main's UpdateBatteringRam, and so is the next one:
  addUnitToTribe gets the tribe as unitID and the shield as tribeID (0x0053C736), with a fixme for each.

compiler-flags-gl.txt gets UpdateShield.cpp only: the two callees it has to see are on main's list already (quick_diff
0.5457 without hasUnitReachedDestination, 0.8707 without deselectUnit, 0.5152 without both).

On main, this round's text pass: main's name for state 108, BOOLEnum calls by truthiness, `++`, `const` on locals, the
fade countdown without its cast, UpdateBatteringRam's names and comments for the scan and its if / return pair for the
first state. The quick_diff listing is the same before and after it.

Measured with real builds (bundled MSVC1400-SP1, function and data resolvers on locally, reccmp raw / normalised), on
main 830fbd5: the small build of this branch's head (503 files, 513 functions: every /GL file of main, every .cpp
that reads Unit::disappearFadeAlphaCountdown, the five units, the fourteen of sourcehold#515, sourcehold#516, sourcehold#518 and sourcehold#533 and
UpdatePriest with their callee closures (UpdateSlave's without playVictory2BikFromPlayerToPlayer's, which doesn't link
in a small build), two callers of standUpIfSeated and every file of a function-visibility group that touches them),
once with OPENSHC_FUNCTION_VISIBILITY_UNITS off and once with it on, BUILD_OK both. The full builds (3,041 files,
3,059 functions: every .cpp but main's three that don't compile, once off and once on) were made before the last text
edits; quick_diff gives the same listing of every file before and after them. It reads 100.0 / 100.0 in all of them.

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* reimplement: SHC_3BB0A8C1_0x0054F860 96.3% 100.0 with OPENSHC_FUNCTION_VISIBILITY_UNITS on

Units::UpdateHunter, from Gynt's draft on sourcehold's reimpl/map-units-updatefunctions (his commits on the file:
76bb533 at 48.51%, 9f9546f at 52.15%, 8ca7861 (the file again, whole) and the style commit 974c32f),
through the forms on our development branches, where its history is (95.3% there). 100% with
OPENSHC_FUNCTION_VISIBILITY_UNITS on, with its entry in this branch's last commit; 96.3% in the default build, so the
status line carries that number, as UpdatePitchman's does.

What the match needed, against the draft:

- Every access reads the unit through DAT_CurrentUnitSlotID::instance; the draft's local copy `int unitID` is gone.
- The states are one if / else-if chain whose arms fall out of it, where the draft had a block per state that returns;
  the shooting state keeps its closing return.
- The shooting state has the "look for another deer, or go home" block once in the arrow part, behind a flag the arrow
  sets, and once behind it (0x0054FF45, 0x0054FF71). The draft had it twice in the arrow part. The flag, arrowFired, is
  the source form that matches: the binary has none, four tests jump to 0x0054FF45.
- The early exits go the original's way round: the other hunter's uid test, "the deer is gone" and "the deer is within
  20" first when chasing, the walk to the post with the failed setDestinationForUnit as the else arm.
- The substate set when the hunter gets back to his post is (mapTimeInTicks & 1) + 2 with no cast (0x00550529), and the
  two height sums of the shot have the terrain height first.

What the option is for: the original knows ten of its callees and treats two, updateBuildingSignpostCounter and
getResourceCountThatCanBeDeposited, as opaque (it reads the slot again behind them). Both are on main's /GL list, so the
default build sees their bodies: quick_diff reads 0.9857 with all /GL callees in the unit, 0.9991 with the ten only,
where the one line left, 0xff against -0x1, is the same instruction. With the option on the two are in other wrapper
units. compiler-flags-gl.txt gets UpdateHunter.cpp, as it has UpdatePitchman.cpp.

On main, this round's text pass: main's names (UnitState_Hunter) for the hunter's states 0 to 11 and 106, through
state.hunter (as main's UpdatePitchman and UpdateWheatFarmer do for theirs), and for the resting state
(USH_RESTING_7); 108 to 111, 113 and 121 keep the shared US_ names; DNE_UNKNOWN_2 and RT_MEAT; BOOLEnum calls by
truthiness, `++` / `--`, `const` on locals, the fade step stored as -2, no `(char)` on the frame tables and the fade
countdown, unused `using` lines dropped, and the local for the slot in front of commitUnitLocation dropped. The
quick_diff listing is the same before and after it.

Measured with real builds (bundled MSVC1400-SP1, function and data resolvers on locally, reccmp raw / normalised), on
main 830fbd5: the small build of this branch's head (503 files, 513 functions: every /GL file of main, every .cpp
that reads Unit::disappearFadeAlphaCountdown, the five units, the fourteen of sourcehold#515, sourcehold#516, sourcehold#518 and sourcehold#533 and
UpdatePriest with their callee closures (UpdateSlave's without playVictory2BikFromPlayerToPlayer's, which doesn't link
in a small build), two callers of standUpIfSeated and every file of a function-visibility group that touches them),
once with OPENSHC_FUNCTION_VISIBILITY_UNITS off and once with it on, BUILD_OK both. The full builds (3,041 files,
3,059 functions: every .cpp but main's three that don't compile, once off and once on) were made before the last text
edits; quick_diff gives the same listing of every file before and after them. With the option on it reads 100.0 /
100.0, with it off 96.3 / 86.9.

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* reimplement: SHC_3BB0A8C1_0x00553AE0 94.6% 100.0 with OPENSHC_FUNCTION_VISIBILITY_UNITS on

Units::UpdateAppleFarmer, from Gynt's draft on sourcehold's reimpl/map-units-updatefunctions (his commits on the file:
69e0814 at 43.32%, 8ca7861 (the file again, whole) and the style commit 974c32f), through the forms on our
development branches, where its history is (94.1% there). 100% with OPENSHC_FUNCTION_VISIBILITY_UNITS on, with its
entry as this branch's last commit leaves it; 94.6% in the default build, so the status line carries that number, as
UpdatePitchman's does.

What the match needed, against the draft:

- The branches of four states the original's way round, read off it one basic block at a time: going to the workplace
  and waiting for a tree (the call that works first), the granary walk (its failure path written out), the deposit (one
  local for getResourceCountThatCanBeDeposited's result).
- The last steps: every access reads the unit through DAT_CurrentUnitSlotID::instance (our parked text still indexed
  some through the draft's `unitID` and one state through a local for the slot, across a setDestinationForUnit call,
  which is not a named callee and stays opaque), and the waiting state stores the slot into the orchard's workers[]
  before it reads the frame, as main's UpdateDairyFarmer does. In quick_diff with the group's callees in the unit
  0.9899 -> 0.9984 (the one line left, 0xff against -0x1, is the same instruction). Only together: 0.9844 without the
  second step, 0.9891 with the state's local kept.

What the option is for: the original reads the slot again behind getResourceCountThatCanBeDeposited, which is on main's
/GL list, so the default build sees its body and keeps the register (quick_diff 0.9820 with it, 0.9984 without).
compiler-flags-gl.txt gets UpdateAppleFarmer.cpp, as it has UpdatePitchman.cpp.

On main, this round's text pass: main's names for states 108 and 121 and for DNE_UNKNOWN_2, BOOLEnum calls by
truthiness, `++` / `--`, `const` on locals, no `(char)` on the frame tables and the fade countdown, the unused `using`
lines and one unused include dropped, USAF_WAITING_1 for the resting state and the farmer's own state type for the
local. The quick_diff listing is the same before and after it.

Measured with real builds (bundled MSVC1400-SP1, function and data resolvers on locally, reccmp raw / normalised), on
main 830fbd5: the small build of this branch's head (503 files, 513 functions: every /GL file of main, every .cpp
that reads Unit::disappearFadeAlphaCountdown, the five units, the fourteen of sourcehold#515, sourcehold#516, sourcehold#518 and sourcehold#533 and
UpdatePriest with their callee closures (UpdateSlave's without playVictory2BikFromPlayerToPlayer's, which doesn't link
in a small build), two callers of standUpIfSeated and every file of a function-visibility group that touches them),
once with OPENSHC_FUNCTION_VISIBILITY_UNITS off and once with it on, BUILD_OK both. The full builds (3,041 files,
3,059 functions: every .cpp but main's three that don't compile, once off and once on) were made before the last text
edits; quick_diff gives the same listing of every file before and after them. With the option on it reads 100.0 /
100.0, with it off 94.6 / 89.6.

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* reimplement: SHC_3BB0A8C1_0x0056E190 100.0% Reimplemented

Units::UpdateJester at 100%, from Gynt's draft on sourcehold's reimpl/map-units-updatefunctions (his commits on the
file: 146023d at 42.00%, 93b5ce0 at 50.14%, 8ca7861 (the file again, whole) and the style commit 974c32f),
through the forms on our development branches, where its history is (94.1% there).

What the match needed, against the draft:

- Every access reads the unit through DAT_CurrentUnitSlotID::instance; the draft's local copy `int unitID` is gone.
- The states are one if / else-if chain whose arms fall out of it, where the draft had a block per state that returns,
  and the first death state tests "the animation is over" first.
- gfxBase is declared at the function's top (with a comment): the original zeroes a register for it in the first block
  and keeps the owner in the frame (0x0056E1C7).
- The random roll is read once into an int local and compared twice (0x0056E336). The text stores the wandering state
  in two arms; the original has the store once (0x0056E3AF) and so has ours, the compiler merges the two arms (one arm
  for both cases loses the match: quick_diff 0.9950 and 0.9894 against 0.9986).
- The last steps, on this main: two locals our parked text had for the slot are gone, one around
  changeDestinationByAmount in the walk-up state and one in front of commitUnitLocation in the fade state. With the
  callees' bodies visible they cost (quick_diff with the /GL callees in the unit 0.9612 -> 0.9936 -> 0.9958). And the
  walk-up state tests `movementSpeed < 1`, a compare with the constant 1 the original holds in bp, where the draft had
  `<= 0`, the same values (0.9958 -> 0.9986; the one line left, 0xff against -0x1, is the same instruction).

compiler-flags-gl.txt gets UpdateJester.cpp only: the eight callees it has to see are on main's list already (quick_diff
without each: checkIfCitizenUnitIsAliveBasedOnState 0.8217, changeDestinationByAmount 0.8870,
hasUnitReachedDestination 0.9627, makeUnitStopWalkingByClearingPathProgressState 0.9859, hasTunnelerNotFinishedDigging
0.9944, commitUnitLocation, setupUnitSharingCurrentTilePosition and setupUnitSharingTileIDs 0.9958 each; 0.5465 without
any).

On main, this round's text pass: main's names for states 2, 3 and 108, BOOLEnum calls by truthiness, `++` / `--`,
`const` on locals, decimal constants, the fade step stored as -2, no `(char)` on the frame tables and the fade
countdown and no `(byte)` on the random number, unused `using` lines and one unused include dropped. The quick_diff
listing is the same before and after it.

Measured with real builds (bundled MSVC1400-SP1, function and data resolvers on locally, reccmp raw / normalised), on
main 830fbd5: the small build of this branch's head (503 files, 513 functions: every /GL file of main, every .cpp
that reads Unit::disappearFadeAlphaCountdown, the five units, the fourteen of sourcehold#515, sourcehold#516, sourcehold#518 and sourcehold#533 and
UpdatePriest with their callee closures (UpdateSlave's without playVictory2BikFromPlayerToPlayer's, which doesn't link
in a small build), two callers of standUpIfSeated and every file of a function-visibility group that touches them),
once with OPENSHC_FUNCTION_VISIBILITY_UNITS off and once with it on, BUILD_OK both. The full builds (3,041 files,
3,059 functions: every .cpp but main's three that don't compile, once off and once on) were made before the last text
edits; quick_diff gives the same listing of every file before and after them. It reads 100.0 / 100.0 in all of them.

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* reimplement: SHC_3BB0A8C1_0x00571C00 91.7% 100.0 with OPENSHC_FUNCTION_VISIBILITY_UNITS on

Units::UpdateSlave, from Gynt's draft on sourcehold's reimpl/map-units-updatefunctions (his commits on the file:
1f2f3bf at 43.44%, cfa098f at 49.88%, 6565c1b, 8ca7861 (the file again, whole) and the style commit
974c32f), through the forms on our development branches, where its history is (87.4% there). 100% with
OPENSHC_FUNCTION_VISIBILITY_UNITS on, with its entry as this branch's last commit leaves it; 91.7% in the default
build, so the status line carries that number, as UpdatePitchman's does.

What the match needed, against the draft:

- Every access reads the unit through DAT_CurrentUnitSlotID::instance; the draft's local copy `int unitID` is gone.
- The fill-moat branch counts the moat's countdown down first, then sets the targeting type, on every path (in the
  source, the path where setXYBasedOnMoatID returns 0 has the two the other way round, as main's UpdateEngineer does;
  the other order loses the match, quick_diff 0.9710 against 0.9792). The moving state tests "delay running" first; its
  moat branch and the digging walk go the original's way round.
- The last steps, on this main (quick_diff with the group's callees in the unit, each on the one before):
  - the parked text's local for the slot across changeDestinationByAmount is gone, the dig state's two frame arms are
    the other way round, and the unit on the dig tile is read once into a local, as in main's UpdatePikeman (0.9555 ->
    0.9654);
  - state 0 ends in a chain of three arms whose last two store the same state, as in main's UpdateEngineer: the
    original branches on 400 only (0x00571EFD), a two-way if / else and an early return for the 400 arm become a setcc
    instead (0.9683), and 0.9654 -> 0.9764 for the chain on the earlier text. The 96 of the middle arm is
    UpdateEngineer's number, by analogy; the original has no 96 here.
  - the moat's owner is read through a local for returnOwnedMoatAtTile's result (0.9764 -> 0.9792).
  What is left of the 0.9792 is how quick_diff spells constants, two-global sums and the timeGetTime import.
- `(int)` on the tick sum in front of `% 40`: the original divides signed (cdq, idiv), as in main's UpdatePikeman; the
  draft's remainder is unsigned, which differs once the sum passes 2^31.

What the option is for: getBuildingFlammabilityFactor is on main's /GL list, so the default build sees its body, and the
original treats it as opaque (quick_diff 0.9284 with it, 0.9792 without).
compiler-flags-gl.txt gets UpdateSlave.cpp, as it has UpdatePitchman.cpp.

On main, this round's text pass: main's names for states 2, 104, 105, 108 and 124 and for CD_UNSPECIFIED and L_MOAT,
BOOLEnum calls by truthiness, `++` / `--`, `const` on locals, no `(char)` on the frame tables and the fade countdown
and no `(short)` where main's UpdatePikeman has none, the string's text above its pointer, one unused include dropped,
CD_SOUTH for the rally's facing, an else-if and one else less around the two returns. The quick_diff listing is the
same before and after it. The compares with -1 (0.9693 with >= 0), the two closing stores of the dig state written on
both paths (0.9622 when written once), and the US_APPEAR stores of the sheet offset and the speed in both arms (0.9759
to 0.9782 hoisted) are measured, with comments in the text.

Measured with real builds (bundled MSVC1400-SP1, function and data resolvers on locally, reccmp raw / normalised), on
main 830fbd5: the small build of this branch's head (503 files, 513 functions: every /GL file of main, every .cpp
that reads Unit::disappearFadeAlphaCountdown, the five units, the fourteen of sourcehold#515, sourcehold#516, sourcehold#518 and sourcehold#533 and
UpdatePriest with their callee closures (UpdateSlave's without playVictory2BikFromPlayerToPlayer's, which doesn't link
in a small build), two callers of standUpIfSeated and every file of a function-visibility group that touches them),
once with OPENSHC_FUNCTION_VISIBILITY_UNITS off and once with it on, BUILD_OK both. The full builds (3,041 files,
3,059 functions: every .cpp but main's three that don't compile, once off and once on) were made before the last text
edits; quick_diff gives the same listing of every file before and after them. With the option on it reads 100.0 /
100.0, with it off 91.7 / 66.3.

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* cmake: function-visibility.txt entries for UpdateShield, UpdateHunter, UpdateAppleFarmer, UpdateJester and UpdateSlave

New entries for UpdateShield, UpdateHunter and UpdateJester; UpdateAppleFarmer's and UpdateSlave's, which main had before
the files existed, each name two more callees. All name only callees that are already members of the group that holds
hasUnitReachedDestination, so the five units join that group's wrapper unit and nothing else moves: no other function
sees a body it didn't see before or loses one.

Each caller-callee pair is measured as sourcehold#491's were (quick_diff, the unit's file with the callee files pasted in front of
it, against the unit alone). The callees tried are the group's members that the unit calls directly or through another
member it calls; one is named when leaving it out lowers the ratio, and the named set reads what the whole set reads:

- UpdateShield 0.5152 alone, 0.9978 with its two: without hasUnitReachedDestination 0.5457, deselectUnit 0.8707.
- UpdateHunter 0.4887 alone, 0.9991 with its ten: without IncrementAndOptionalUpdateAVValueRelated 0.6953,
  checkIfCitizenUnitIsAliveBasedOnState 0.9004, hasUnitReachedDestination 0.9201, ComputeGoodsProduced 0.9840,
  SetStateToFreetimeWalking 0.9880, UpdateWorker_ConsiderTakingABreakUnk and ConsiderHavingABreakNowUnk 0.9907 each,
  commitUnitLocation, setupUnitSharingCurrentTilePosition and setupUnitSharingTileIDs 0.9929 each. Not named:
  makeUnitStopWalkingByClearingPathProgressState (no change).
- UpdateAppleFarmer 0.5793 alone, 0.9984 with its seven: without checkIfCitizenUnitIsAliveBasedOnState 0.8558,
  IncrementAndOptionalUpdateAVValueRelated 0.8580, ComputeGoodsProduced 0.8918, hasUnitReachedDestination 0.9408,
  SetStateToFreetimeWalking 0.9891; new in the entry, UpdateWorker_ConsiderTakingABreakUnk and
  ConsiderHavingABreakNowUnk, 0.9713 each. Not named: makeUnitStopWalkingByClearingPathProgressState (no change).
- UpdateJester 0.5465 alone, 0.9986 with its eight: the numbers are in its commit.
- UpdateSlave 0.5410 alone, 0.9792 with its three: without hasUnitReachedDestination 0.5245; new in the entry, xyAreValid
  0.9173 and changeDestinationByAmount 0.9764.

On top of the named callees, each /GL callee outside the group that the unit calls was tried one at a time, without its
own callees: only updateBuildingSignpostCounter (UpdateHunter 0.9933), getResourceCountThatCanBeDeposited (UpdateHunter
0.9915, UpdateAppleFarmer 0.9820) and getBuildingFlammabilityFactor (UpdateSlave 0.9284) change a ratio, and all lower it.

Full build of every file with the option on (3,041 files, 3,059 functions, BUILD_OK, 0 failures), against main
830fbd5's tree built the same way (3,036 files, 3,054 functions): nothing on main reads differently, and the five
units read 100.0 / 100.0. It was made before the last text edits of the five units; quick_diff gives the same listing
of every file before and after them. The generator makes 25 wrapper units holding 160 source files (155 on main): the
five units join the group that holds hasUnitReachedDestination, and no other file changes group.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
gynt pushed a commit to gynt/OpenSHC that referenced this pull request Dec 2, 2026
…t and UpdateMiller (sourcehold#535)

sourcehold#534 gave the nine /GL units of sourcehold#515, sourcehold#516 and sourcehold#518 that had no entry in cmake/function-visibility.txt one, and left
three for a follow-up: UpdatePeasant and UpdateMiller (sourcehold#533), and UpdatePriest, main's own unit. This adds the three,
each at its address, its callees in address order. All three are on cmake/compiler-flags-gl.txt already (UpdatePriest
was there before those PRs); that file stays as it is. With OPENSHC_FUNCTION_VISIBILITY_UNITS on, the members of every
group leave the /GL list, among them the helpers in the group that holds hasUnitReachedDestination, so a /GL unit
without an entry no longer sees them: in main e62246a's full build in that mode, the build the real builds below
compare against, UpdatePriest reads 72.0% / 68.9%, UpdatePeasant 49.3% / 48.7% and UpdateMiller 51.7% / 46.2% (raw /
normalised: reccmp_report.py's normalised figure ignores call and tail-jump targets and resolver addresses).

UpdatePriest's entry names only callees that are already members of the group that holds hasUnitReachedDestination, as
sourcehold#534's do. UpdatePeasant's and UpdateMiller's name members of that group and, each, one more /GL callee that is not in
it: getDestination2EqualsGivenCoordinates for UpdatePeasant and standUpIfSeated for UpdateMiller. With the members
alone they read 96.0% / 87.1% and 96.5% / 93.0% in an earlier full build of this branch with the option on (below).
With that callee they read 100.0%, so it joins the group, and with the option on, CMake takes five more files off the
/GL list: the three units, getDestination2EqualsGivenCoordinates and standUpIfSeated. Nothing else moves:
getDestination2EqualsGivenCoordinates is called by UpdatePeasant only, and standUpIfSeated by UpdateMiller,
standUpAllTribeUnits and updatePeasantSeatingAtBuilding (neither of the last two is on the /GL list or has an entry, so
neither saw its body before or sees it now). No other function sees a body it did not see before. The three units'
other /GL callees (setDestinationForUnit, resetUnitMovementState, clearHiddenFlagAndUpdatePosition,
setWorkplaceBuildingEntryAsTarget, selectNewBlessingTarget, setUnitFacingDirectionTowardsTarget and the rest of their
closures) stay opaque to them.

Each caller-callee pair is measured as sourcehold#491's and sourcehold#534's were: the unit's file compiled with the callee files pasted in
front of it, against the unit alone, quick_diff on main e62246a, with the data resolvers switched on by
tools/reimplementation-control/enable_reimplemented_data.py and the function resolver of every .cpp in the build list
by tools/reimplementation-helper/batch/enable_local_functions.py (locally, not committed). The callees tried are the
group's members that the unit calls directly or through another member it calls (commitUnitLocation's callee
setupUnitSharingCurrentTilePosition and, behind it, setupUnitSharingTileIDs, included), not callees reached only
through functions outside the group; and, for UpdatePeasant and UpdateMiller, each /GL callee outside the group that
they call, one at a time on top of the named members, pasted without its own callees unless it says "with its callees".
A callee is listed when leaving it out of the set lowers the ratio; the listed set reads what the whole set reads.
quick_diff is stricter than reccmp about register names; the real builds read the units at 100.0%.

- UpdatePriest: 0.7534 alone, 0.9986 with its 5. Left out, makeUnitStopWalkingByClearingPathProgressState reads
  0.9891, IncrementAndOptionalUpdateAVValueRelated 0.8859, checkIfCitizenUnitIsAliveBasedOnState 0.9510,
  hasUnitReachedDestination 0.9680, changeDestinationByAmount 0.9850. commitUnitLocation, its callee
  setupUnitSharingCurrentTilePosition and, behind it, setupUnitSharingTileIDs change nothing.
- UpdatePeasant: 0.5329 alone, 0.9941 with its 3. Left out, checkIfCitizenUnitIsAliveBasedOnState reads 0.5880,
  getDestination2EqualsGivenCoordinates 0.9725, hasUnitReachedDestination 0.9684. Outside the group, on top of the two
  members, clearHiddenFlagAndUpdatePosition (with its callees) and setDestinationForUnit change nothing.
- UpdateMiller: 0.5531 alone, 0.9973 with its 13. Left out, getBuildingResourceAmountByUid reads 0.9722,
  setupUnitSharingTileIDs 0.9947, standUpIfSeated 0.9913, sitDownIfStanding 0.9953,
  IncrementAndOptionalUpdateAVValueRelated 0.8442, ConsiderHavingABreakNowUnk 0.9914, SetStateToFreetimeWalking
  0.9707, ComputeGoodsProduced 0.9661, checkIfCitizenUnitIsAliveBasedOnState 0.8008, hasUnitReachedDestination 0.9593,
  setupUnitSharingCurrentTilePosition 0.9947, UpdateWorker_ConsiderTakingABreakUnk 0.9914, commitUnitLocation 0.9947.
  makeUnitStopWalkingByClearingPathProgressState changes nothing. Outside the group, on top of the twelve members,
  resetUnitMovementState (with its callees), setDestinationForUnit, setWorkplaceBuildingEntryAsTarget,
  addResourceToStockpile, buildingIsAccessible, updateBuildingSignpostCounter and
  getStorageBuildingForResourceTypeAndAmount change nothing; the last four are members of other groups, so with the
  option on they are off the /GL list already, and naming one would merge two groups.

With every .cpp of main as the build list, cmake/function-visibility-units.py makes 25 wrapper units holding 155
source files (150 before): the three units and the two callees join the group that holds hasUnitReachedDestination, and
no other file changes group. CMake reads this file only with the option on, so the default build is unchanged.

Real builds on main e62246a, BUILD_OK and 0 failures each:
- full, option on: every .cpp of main with all function and data resolvers on (the 3 files that don't compile there
  left out: findBestAttackTileByPathCost, resetTileAndClearMoat, TransformAndRenderPercentage), 3,036 files and 3,054
  functions, against main e62246a built the same way. Two full builds of the branch's side: one with the three
  entries without getDestination2EqualsGivenCoordinates and standUpIfSeated (UpdatePriest's as it is now), which reads
  UpdatePeasant 96.0% / 87.1%, UpdateMiller 96.5% / 93.0% and UpdatePriest 100.0% / 100.0%; and this change, which
  reads the three 100.0% / 100.0%. Against main nothing else reads differently in either.
- small, both modes: main's /GL list, every .cpp that reads Unit::disappearFadeAlphaCountdown, the twelve units of
  sourcehold#515, sourcehold#516 and sourcehold#518 (nine in sourcehold#534, three with an entry before it) and these three with their callee closures,
  standUpAllTribeUnits and updatePeasantSeatingAtBuilding, and every file of a group that touches them, 494 files and
  504 functions. All fifteen units read 100.0% / 100.0% in both modes. UpdateFireBallistaBuilding: with the option
  off, where this file is not read, 100.0% / 100.0% with the 494 files and 99.6% / 95.5% with 492 (without
  standUpAllTribeUnits and updatePeasantSeatingAtBuilding), so its reading changes with the set of files built; with
  the option on, 99.6% / 95.5% with the 494 files, and main was not built with those files and the option on, so that
  case is not settled. It reads 100.0% / 100.0% in both full builds, this change's and main's.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants